import Mock from "mockjs";
import XEUtils from "xe-utils";
import { commonData, listPage } from "./util";
Mock.mock(/\/api\/list/, "get", function (options: any) {
    let opts = XEUtils.parseUrl(options.url);
    let query = opts.searchQuery;
    return commonData(
        Mock.mock(
            listPage({
                page_num: query.page_num || 1,
                page_size: query.page_size,
                total: 100,
                data: <any>{
                    name: "@cword(2, 5)",
                    price: "@integer(100, 1000)",
                    count: "@integer(1, 100)",
                    imgUrl: '@dataImage("200x200", "商品图片")',
                },
            }),
        ),
    );
});

Mock.mock(/\/api\/tablist/, "get", function (options: any) {
    let opts = XEUtils.parseUrl(options.url);
    let query = opts.searchQuery;
    return commonData(
        Mock.mock(
            listPage({
                page_num: query.page_num || 1,
                page_size: query.page_size,
                total: 100,
                data: <any>{
                    name: "@cword(2, 5)",
                    price: "@integer(100, 1000)",
                    count: "@integer(1, 100)",
                    imgUrl: '@dataImage("200x200", "商品图片")',
                },
            }),
        ),
    );
});

export default Mock;
